package com.zxa.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created by zxa on 17-7-22.
 */
public class DBUtil
{

    public static Connection getConnection(){
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Connection con = null;
        String url = "jdbc:mysql://123.207.151.147:3306/MyTest" ;
        String username = "zxa" ;
        String password = "zxa" ;
        try{
            con =
                    DriverManager.getConnection(url , username , password ) ;
        }catch(SQLException se){
            System.out.println("数据库连接失败！");
            se.printStackTrace() ;
        }
        return  con;
    }

    public static void main(String[] args)
    {
        if(getConnection()!=null)
            System.out.println("链接成功");
    }



}
